# -*- coding: utf-8 -*-
"""
角色名字生成器
"""

import random
from typing import List


class CharacterGenerator:
    """角色名字生成器"""
    
    def __init__(self):
        # 中文姓氏
        self.chinese_surnames = [
            "李", "王", "张", "刘", "陈", "杨", "赵", "黄", "周", "吴",
            "徐", "孙", "胡", "朱", "高", "林", "何", "郭", "马", "罗",
            "梁", "宋", "郑", "谢", "韩", "唐", "冯", "于", "董", "萧",
            "程", "曹", "袁", "邓", "许", "傅", "沈", "曾", "彭", "吕",
            "苏", "卢", "蒋", "蔡", "贾", "丁", "魏", "薛", "叶", "阎"
        ]
        
        # 中文名字（男性）
        self.chinese_male_names = [
            "伟", "强", "磊", "军", "洋", "勇", "艺", "杰", "涛", "明",
            "超", "辉", "华", "鹏", "飞", "宇", "峰", "博", "志", "俊",
            "建", "斌", "龙", "海", "东", "波", "凯", "晨", "阳", "帆",
            "浩", "宏", "庆", "亮", "栋", "天", "文", "新", "力", "旭"
        ]
        
        # 中文名字（女性）
        self.chinese_female_names = [
            "丽", "娜", "敏", "静", "秀", "慧", "美", "雯", "萍", "红",
            "燕", "梅", "琳", "晶", "欣", "蓉", "洁", "玲", "芳", "倩",
            "莹", "雪", "霞", "春", "月", "婷", "媛", "颖", "菲", "珊",
            "薇", "雅", "青", "晓", "凤", "兰", "露", "君", "瑶", "诗"
        ]
        
        # 西方名字（男性）
        self.western_male_names = [
            "Alexander", "William", "Benjamin", "Michael", "David", "James",
            "Robert", "John", "Daniel", "Christopher", "Matthew", "Anthony",
            "Mark", "Donald", "Steven", "Paul", "Andrew", "Joshua", "Kenneth",
            "Kevin", "Brian", "George", "Edward", "Ronald", "Timothy", "Jason"
        ]
        
        # 西方名字（女性）
        self.western_female_names = [
            "Emma", "Olivia", "Sophia", "Isabella", "Ava", "Mia", "Emily",
            "Abigail", "Madison", "Elizabeth", "Charlotte", "Avery", "Sofia",
            "Chloe", "Ella", "Harper", "Amelia", "Aubrey", "Addison", "Evelyn",
            "Natalie", "Grace", "Hannah", "Zoey", "Victoria", "Lillian"
        ]
        
        # 日式名字（男性）
        self.japanese_male_names = [
            "太郎", "次郎", "三郎", "健", "诚", "翔", "大輔", "拓哉",
            "雄太", "智也", "裕太", "悠人", "陽向", "湊", "蓮", "樹",
            "颯", "陸", "新", "碧", "心", "奏", "仁", "廉"
        ]
        
        # 日式名字（女性）
        self.japanese_female_names = [
            "花子", "美子", "恵子", "智子", "由美", "真理", "美咲", "美羽",
            "結愛", "陽菜", "杏", "さくら", "美月", "愛", "花音", "心春",
            "結衣", "莉子", "美桜", "心愛", "結月", "凛", "紬", "澪"
        ]
    
    def generate_chinese_name(self, gender: str = "random") -> str:
        """生成中文名字
        
        Args:
            gender: 性别 ("male", "female", "random")
            
        Returns:
            生成的中文名字
        """
        surname = random.choice(self.chinese_surnames)
        
        if gender == "random":
            gender = random.choice(["male", "female"])
        
        if gender == "male":
            given_name = random.choice(self.chinese_male_names)
            # 有概率生成双字名
            if random.random() < 0.3:
                given_name += random.choice(self.chinese_male_names)
        else:
            given_name = random.choice(self.chinese_female_names)
            # 有概率生成双字名
            if random.random() < 0.3:
                given_name += random.choice(self.chinese_female_names)
        
        return surname + given_name
    
    def generate_western_name(self, gender: str = "random") -> str:
        """生成西方名字
        
        Args:
            gender: 性别 ("male", "female", "random")
            
        Returns:
            生成的西方名字
        """
        if gender == "random":
            gender = random.choice(["male", "female"])
        
        if gender == "male":
            return random.choice(self.western_male_names)
        else:
            return random.choice(self.western_female_names)
    
    def generate_japanese_name(self, gender: str = "random") -> str:
        """生成日式名字
        
        Args:
            gender: 性别 ("male", "female", "random")
            
        Returns:
            生成的日式名字
        """
        if gender == "random":
            gender = random.choice(["male", "female"])
        
        if gender == "male":
            return random.choice(self.japanese_male_names)
        else:
            return random.choice(self.japanese_female_names)
    
    def generate_names(self, count: int = 5, style: str = "chinese", gender: str = "random") -> List[str]:
        """批量生成名字
        
        Args:
            count: 生成数量
            style: 风格 ("chinese", "western", "japanese", "mixed")
            gender: 性别 ("male", "female", "random")
            
        Returns:
            生成的名字列表
        """
        names = []
        
        for _ in range(count):
            if style == "mixed":
                current_style = random.choice(["chinese", "western", "japanese"])
            else:
                current_style = style
            
            if current_style == "chinese":
                name = self.generate_chinese_name(gender)
            elif current_style == "western":
                name = self.generate_western_name(gender)
            elif current_style == "japanese":
                name = self.generate_japanese_name(gender)
            else:
                name = self.generate_chinese_name(gender)
            
            names.append(name)
        
        return names 